package com.learn.springboot.config.interceptor;

import com.learn.springboot.interceptor.OneInterceptor;
import com.learn.springboot.interceptor.TwoInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

/**
 * 配置拦截器
 * 使用注解配置拦截器
 * 配置WebMVCConfig需要实现WebMvcConfigurer接口 WebMvcConfig implements WebMvcConfigurer
 * 配置拦截器则是在addInterceptors方法中设置拦截器,以及拦截路径
 * @author wangxing
 * @version 2020/8/3 13:59 Administrator
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(new TwoInterceptor()).addPathPatterns("/**");
        registry.addInterceptor(new OneInterceptor()).addPathPatterns("/**");
    }
}
